<template>
  <div class="index">

    <div class="center">
      <left></left>
      <div class="right">
        <top></top>
        <div class="hei10"></div>

        <div class="where" style="background: #fff; padding: 10px 30px; font-size: 14px; color: #595959;">
          当前位置：
          <router-link to="/index" style="color: #409eff;">分销后台</router-link>>
          <router-link to="/productionBasismanag" style="color: #409eff;">产品渠道管理</router-link>>
          修改产品
        </div>

        <div class="hei10"></div>
        <div class="addpro" style="width: calc(100vw - 230px);">

          <div v-loading="loading">

            <el-steps :active="1" align-center>
              <el-step title="定义基础产品信息" description="设置分类、定制生产规则"></el-step>
              <el-step title="定义销售页信息" description="对外宣传销售话术"></el-step>
              <el-step title="设置佣金及分销商可见" description="设置那些分销商可以销售，给多少佣金"></el-step>
              <el-step title="确认发布" description="上线销售发展用户"></el-step>
            </el-steps>


            <div class="step">
              <div class="tilte kflexbc" style="width: 100%;">
                <div>定义基础产品信息</div>
                <!-- <el-tooltip class="item" effect="light" content="基础信息不对外展示，仅商铺内部可见" placement="top">
                            		<i class="el-icon-question" style="color: #409EFF; font-size: 25px;"></i>
                            	</el-tooltip> -->
              </div>
              <div class="con" style="padding: 60px; font-size: 14px; color: #666;">
                <div class="kflexc" style="margin-bottom: 20px;">
                  <div class="kflexc">
                    <div class="kflexc"
                      style="width: 120px; text-align: right; margin-right: 20px; justify-content: flex-end;">
                      <div style="margin-right: 10px;"><span
                          style="color: rgb(22, 119, 255); font-style: italic; font-weight: bold;">AI</span></div>
                      <div style="margin-right: 10px;"><span
                          style="color: #f00; font-style: italic; font-weight: bold;">*</span></div>
                      <div>运营商:</div>
                    </div>
                    <div>
                      <el-select v-model="form.operator" style="width: 300px;" placeholder="请选择运营商:">
                        <el-option v-for="item in sanlist" :key="item.id" :label="item.name"
                          :value="item.id"></el-option>
                      </el-select>
                    </div>
                  </div>
                  <div class="kflexc">
                    <div class="kflexc"
                      style="width: 120px; text-align: right; margin-right: 20px; justify-content: flex-end;">
                      <div style="margin-right: 10px;"><span
                          style="color: #f00; font-style: italic; font-weight: bold;">*</span></div>
                      <div>产品类型:</div>
                    </div>
                    <div>
                      <el-select v-model="form.plan_type_id" style="width: 300px;" placeholder="请选择产品类型:">
                        <el-option v-for="item in typelist" :key="item.id" :label="item.name"
                          :value="item.id"></el-option>
                      </el-select>
                      <el-button type="primary" round plain @click="taglog = true"
                        style="margin-left: 10px;">自定义</el-button>
                    </div>
                  </div>
                </div>
                <div class="kflexc" style="margin-bottom: 20px;">
                  <div class="kflexc">
                    <div class="kflexc"
                      style="width: 120px; text-align: right; margin-right: 20px; justify-content: flex-end;">
                      <div style="margin-right: 10px;"><span
                          style="color: #f00; font-style: italic; font-weight: bold;">*</span></div>
                      <div>产品名称:</div>
                    </div>
                    <div>
                      <el-input v-model="form.name" :class="{redbor:!sub1}" @input="nijiushiwodeweiyi1"
                        style="width: 300px;" placeholder="产品名称"></el-input>
                    </div>
                  </div>
                  <div class="kflexc">
                    <div class="kflexc"
                      style="width: 120px; text-align: right; margin-right: 20px; justify-content: flex-end;">
                      <div style="margin-right: 10px;"><span
                          style="color: #f00; font-style: italic; font-weight: bold;">*</span></div>
                      <div>产品编号:</div>
                    </div>
                    <div class="kflexc">
                      <el-input v-model="form.sku" :class="{redbor:!sub2}" style="width: 300px;" placeholder="产品编号"
                        @input="nijiushiwodeweiyi2"></el-input>
                      <div style="margin-left: 20px;">
                        <el-checkbox style="margin-left: 20px; margin-right: 10px;" v-model="form.is_force_recharge"
                          :true-label="1" :false-label="0">强充产品</el-checkbox>
                        <el-tooltip class="item" effect="light" content="该产品必须充值才能激活，勾选后该产品的激活状态“已激活”自动变更为“激活且充值”。"
                          placement="top">
                          <i class="el-icon-question" style="color: #409EFF; font-size: 20px;"></i>
                        </el-tooltip>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="kflexc" style="margin-bottom: 20px;">
                  <div class="kflexc">
                    <div class="kflexc"
                      style="width: 120px; text-align: right; margin-right: 20px; justify-content: flex-end;">
                      <div style="margin-right: 10px;"><span
                          style="color: rgb(22, 119, 255); font-style: italic; font-weight: bold;">AI</span></div>
                      <div style="margin-right: 10px;"><span
                          style="color: #f00; font-style: italic; font-weight: bold;">*</span></div>
                      <div>归属地:</div>
                    </div>
                    <div>
                      <el-cascader @change="changeaddress" style="width: 300px;" v-model="form.citys"
                        :options="citylist"></el-cascader>
                    </div>
                  </div>
                  <div class="kflexc">
                    <div class="kflexc"
                      style="width: 120px; text-align: right; margin-right: 20px; justify-content: flex-end;">
                      <div>所属渠道:</div>
                    </div>
                    <div>
                      <el-select v-model="form.product_source" style="width: 300px;" clearable filterable
                        placeholder="请选所属渠道:">
                        <el-option v-for="(item,index) in qudaolists" :key="index" :label="item"
                          :value="item"></el-option>
                      </el-select>
                      <el-button type="primary" @click="goopen('productionBasismanag/qudaoguanli')" round plain
                        style="margin-left: 10px;">所属渠道管理</el-button>
                    </div>
                  </div>
                </div>

                <div class="kflexc" style="margin-bottom: 20px;">
                  <div class="kflexc">

                    <div class="kflexc"
                      style="width: 120px; text-align: right; margin-right: 20px; justify-content: flex-end;">
                      <div style="margin-right: 10px;"><span
                          style="color: #f00; font-style: italic; font-weight: bold;">*</span></div>
                      <div>生产定义:</div>
                    </div>

                    <div style="background: #F3F5F8; padding: 30px; border-radius: 10px; width: calc(100vw - 550px);">
                      <div class="kflexc" style="margin-bottom: 20px;">
                        <div style="margin-right: 20px;">是否需要身份证号码:</div>
                        <div>
                          <el-radio-group v-model="form.need_num">
                            <el-radio label="0">不需要</el-radio>
                            <el-radio label="1">需要</el-radio>
                          </el-radio-group>
                          <el-tooltip class="item" effect="light" content="下单是否需要身份证号码，选择后订单必须有身份证号才会进入审核生产。"
                            placement="top">
                            <i class="el-icon-question"></i>
                          </el-tooltip>
                          <span class="zengzhi">
                            <el-checkbox v-model="shoufei2" @change="shoufeichange()">国政通校验(收费)</el-checkbox>
                            <el-tooltip class="item" effect="light" content="会自动审核用户身份证号是否通过国政通验证,该项为增值收费项目0.2元/次"
                              placement="top">
                              <i class="el-icon-question"></i>
                            </el-tooltip>
                          </span>
                          <span class="zengzhi" style="margin-left: 0;">
                            <el-checkbox v-model="shoufei3" @change="shoufeichange()">联通开卡校验(收费)</el-checkbox>
                            <el-tooltip class="item" effect="light" content="自动检查用户是否存在一证五户、黑名单问题,该项为增值收费项目0.1元/次"
                              placement="top">
                              <i class="el-icon-question"></i>
                            </el-tooltip>
                          </span>
                        </div>
                      </div>
                      <div class="kflexc" style="margin-bottom: 20px;">
                        <div style="margin-right: 20px;">是否需要身份证照片:</div>
                        <div>
                          <el-radio-group v-model="form.real_name_type">
                            <el-radio label="1">不需要</el-radio>
                            <el-radio label="0">需要</el-radio>
                            <el-radio label="3">需要照片但不审核</el-radio>
                          </el-radio-group>
                          <el-tooltip class="item" effect="light" content="下单是否需要三张身份证照片，选择后订单必须有照片才会进入审核生产。"
                            placement="top">
                            <i class="el-icon-question"></i>
                          </el-tooltip>
                          <span class="zengzhi">
                            <el-checkbox v-model="shoufei1" @change="shoufeichange()">使用智能照片审核(收费)</el-checkbox>
                            <el-tooltip class="item" effect="light" content="系统自动识别身份证照片，并将识别的身份证号与订单中的身份证号对照，通过的自动过审。
                                          注：对于照片有比例要求、大小要求的、请勿使用该功能。" placement="top">
                              <i class="el-icon-question" style="color: #409EFF; font-size: 20px;"></i>
                            </el-tooltip>
                          </span>
                        </div>
                      </div>
                      <div class="kflexc">
                        <div style="margin-right: 20px;">生产地址:</div>
                        <div class="bai"><el-input v-model="form.produce_address" style="width: 300px;"
                            placeholder="生产地址"></el-input></div>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="kflexc" style="margin-bottom: 20px;">
                  <div class="kflexc">

                    <div class="kflexc"
                      style="width: 120px; text-align: right; margin-right: 20px; justify-content: flex-end;">
                      <div style="margin-right: 10px;"><span
                          style="color: rgb(22, 119, 255); font-style: italic; font-weight: bold;">AI</span></div>
                      <div>限制条件:</div>
                    </div>

                    <div style="background: #F3F5F8; padding: 30px; border-radius: 10px;  width: calc(100vw - 550px);">
                      <div class="kflexc" style="margin-bottom: 20px;">
                        <div style="margin-right: 20px; width: 120px;">不发货地址:</div>
                        <div class="bai">
                          <el-radio v-model="form.warn_area_type" label="1" style="display: block;">
                            <span style=" margin-right: 10px;">不发货地址:</span>
                            <el-button type="primary" size="mini" plain
                              @click="keylog = true">已设置{{mingan.citys.length}}个</el-button>
                          </el-radio>
                        </div>
                      </div>
                      <div class="kflexc" style="margin-bottom: 20px;">
                        <div style="margin-right: 20px; width: 120px;">&nbsp;</div>
                        <div class="bai">
                          <el-radio v-model="form.warn_area_type" label="2" style="display: block;">
                            <span style=" margin-right: 10px;">只发货省市:</span>
                            <el-cascader :options="options" v-model="form.deliver_province" style="width: 300px;"
                              collapse-tags :props="props" clearable>
                            </el-cascader>
                          </el-radio>

                        </div>
                      </div>
                      <div style="margin-bottom: 20px;color: #606266;">
                        <el-checkbox :true-label="1" :false-label="0" v-model="form.is_identify_id"
                          style="margin-right: 0;"></el-checkbox>
                        按身份证号前4位识别
                        <el-button @click="idcardshow" style="margin-left:10px" type="primary" size="mini" plain>
                          已设置{{tagssure.length}}个</el-button>
                      </div>
                      <div class="kflexc" style="margin-bottom: 20px;">
                        <div style="margin-right: 20px; width: 120px;">年龄限制(周岁):</div>
                        <div class="bai">
                          <el-input v-model="form.min_age" style="width: 150px;" placeholder="最小年龄"></el-input>
                          ——
                          <el-input v-model="form.max_age" style="width: 150px;" placeholder="最大年龄"></el-input>
                        </div>
                      </div>
                      <div class="kflexc">
                        <div class="kflexc" style="margin-right: 50px;">
                          <div style="margin-right: 20px; width: 120px;">单人开卡数量限制:</div>
                          <div class="bai">
                            <el-select v-model="form.max_purchase" style="width: 300px;" placeholder="请选择最大开卡数量:">
                              <el-option label="不限制" value="-1"></el-option>
                              <el-option label="1" value="1"></el-option>
                              <el-option label="2" value="2"></el-option>
                              <el-option label="3" value="3"></el-option>
                              <el-option label="4" value="4"></el-option>
                              <el-option label="5" value="5"></el-option>
                            </el-select>
                          </div>
                        </div>
                        <div class="kflexc">
                          <div style="margin-right: 20px;">检测周期:</div>
                          <div class="bai">
                            <el-select v-model="xiaomingtime" style="width: 300px;" placeholder="检测周期:">
                              <el-option label="不限制" value="0"></el-option>
                              <el-option label="1个月" value="1"></el-option>
                              <el-option label="2个月" value="2"></el-option>
                              <el-option label="3个月" value="3"></el-option>
                              <el-option label="4个月" value="4"></el-option>
                              <el-option label="5个月" value="5"></el-option>
                              <el-option label="6个月" value="6"></el-option>
                              <el-option label="7个月" value="7"></el-option>
                              <el-option label="8个月" value="8"></el-option>
                              <el-option label="9个月" value="9"></el-option>
                              <el-option label="10个月" value="10"></el-option>
                              <el-option label="11个月" value="11"></el-option>
                              <el-option label="12个月" value="12"></el-option>
                            </el-select>
                          </div>
                        </div>
                      </div>

                    </div>
                  </div>
                </div>
                <div class="kflexc" style="margin-bottom: 20px;">
                  <div class="kflexc">

                    <div class="kflexc"
                      style="width: 120px; text-align: right; margin-right: 20px; justify-content: flex-end;">
                      <div style="margin-right: 10px;"><span
                          style="color: #f00; font-style: italic; font-weight: bold;">*</span></div>
                      <div>风险预警设置:</div>
                    </div>

                    <div style="background: #F3F5F8; padding: 30px; border-radius: 10px;  width: calc(100vw - 550px);"
                      v-loading="fxloading">
                      <div class="kflexc" style="margin-bottom: 20px;">
                        <div :class="fxs.type == 0 ? 'fxli fxact' : 'fxli' " @click="changetype(0)"><span
                            v-if="fxs.type == 0" style="margin-right: 10px; font-size: 14px;"><i
                              class="el-icon-success"></i></el-radio></span>使用全局默认方案</div>
                        <div :class="fxs.type == 1 ? 'fxli fxact' : 'fxli' " @click="changetype(1)"><span
                            v-if="fxs.type == 1" style="margin-right: 10px; font-size: 14px;"><i
                              class="el-icon-success"></i></el-radio></span>使用自定义方案</div>
                      </div>
                      <div class="kflexc" style="margin-bottom: 20px;">
                        <div style="margin-right: 20px;">一证五户检测:</div>
                        <div class="bai" style="margin-right: 50px;">
                          <el-select v-model="fxs.id_card" style="width:300px;" :disabled="fx">
                            <el-option label="不检测" value="0"></el-option>
                            <el-option label="检测" value="1"></el-option>
                          </el-select>
                        </div>
                        <div style="margin-right: 20px;">检测周期:</div>
                        <div class="bai">
                          <el-select v-model="fxs.id_card_range" style="width:300px;" :disabled="fx">
                            <el-option label="不限制" value="9999"></el-option>
                            <el-option label="最近30天" value="30"></el-option>
                            <el-option label="最近60天" value="60"></el-option>
                            <el-option label="最近90天" value="90"></el-option>
                            <el-option label="最近120天" value="120"></el-option>
                            <el-option label="最近150天" value="150"></el-option>
                            <el-option label="最近180天" value="180"></el-option>
                          </el-select>
                        </div>
                      </div>

                      <div class="kflexc" style="margin-bottom: 20px;">
                        <div style="margin-right: 20px;">联系电话重复:</div>
                        <div class="bai" style="margin-right: 50px;">
                          <el-input v-model="fxs.address_mobile" style="width:300px;" :disabled="fx"
                            placeholder="输入上限数值"></el-input>
                        </div>
                        <div style="margin-right: 20px;">检测周期:</div>
                        <div class="bai" style="margin-right: 50px;">
                          <el-select v-model="fxs.address_mobile_range" style="width:300px;" :disabled="fx">
                            <el-option label="不限制" value="9999"></el-option>
                            <el-option label="最近30天" value="30"></el-option>
                            <el-option label="最近60天" value="60"></el-option>
                            <el-option label="最近90天" value="90"></el-option>
                            <el-option label="最近120天" value="120"></el-option>
                            <el-option label="最近150天" value="150"></el-option>
                            <el-option label="最近180天" value="180"></el-option>
                          </el-select>
                        </div>
                        <div style="margin-right: 20px;">检测范围:</div>
                        <div class="bai" style="margin-right: 50px;">
                          <el-select v-model="fxs.sitmobile" style="width:300px;" :disabled="fx">
                            <el-option label="本店铺" value="0"></el-option>
                            <el-option label="系统全部店铺" value="1"></el-option>
                            <el-option label="本产品" value="2"></el-option>
                          </el-select>
                        </div>
                      </div>

                      <div class="kflexc" style="margin-bottom: 20px;">
                        <div style="margin-right: 20px;">收货地址重复:</div>
                        <div class="bai" style="margin-right: 50px;">
                          <el-input v-model="fxs.address" :disabled="fx" style="width:300px;"
                            placeholder="输入上限数值"></el-input>
                        </div>
                        <div style="margin-right: 20px;">检测周期:</div>
                        <div class="bai" style="margin-right: 50px;">
                          <el-select v-model="fxs.address_range" style="width:300px;" :disabled="fx">
                            <el-option label="不限制" value="9999"></el-option>
                            <el-option label="最近30天" value="30"></el-option>
                            <el-option label="最近60天" value="60"></el-option>
                            <el-option label="最近90天" value="90"></el-option>
                            <el-option label="最近120天" value="120"></el-option>
                            <el-option label="最近150天" value="150"></el-option>
                            <el-option label="最近180天" value="180"></el-option>
                          </el-select>
                        </div>
                        <div style="margin-right: 20px;">检测范围:</div>
                        <div class="bai" style="margin-right: 50px;">
                          <el-select v-model="fxs.sitaddress" style="width:300px;" :disabled="fx">
                            <el-option label="本店铺" value="0"></el-option>
                            <el-option label="系统全部店铺" value="1"></el-option>
                            <el-option label="本产品" value="2"></el-option>
                          </el-select>
                        </div>
                      </div>

                      <div class="fxbtm" style="padding-left: 110px;">
                        <div v-if="fx"><el-button type="primary" size="small" @click="fx = false">修改默认方案</el-button>
                        </div>
                        <div v-if="!fx&&fxs.type==0">
                          <el-button type="primary" size="small" v-if="fxsidsave == ''"
                            @click="savefx">保存默认方案</el-button>
                          <el-button type="primary" size="small" v-if="fxsidsave != ''"
                            @click="fixfx">修改默认方案</el-button>
                          <el-button type="primary" size="small" @click="fx = true">取消修改默认方案</el-button>
                        </div>
                        <div v-if="!fx&&fxs.type==1">
                          <el-button type="primary" size="small" v-if="fxs.id == ''" @click="savefx">保存自定义</el-button>
                          <el-button type="primary" size="small" v-if="fxs.id != ''" @click="fixfx">保存修改</el-button>
                        </div>
                        <div class="red" v-if="!fx&&fxs.type==0">注：修改默认方案会导致使用默认方案的所有基础产品风控规则变更</div>
                      </div>
                      <div class="fxbtm hui" style="margin-top: 20px;">注：风险数据监测范围均仅限于本店铺数据，不包含运营商数据</div>


                    </div>
                  </div>
                </div>
                <div class="kflexc" style="margin-bottom: 20px;">
                  <div class="kflexc">
                    <div class="kflexc"
                      style="width: 120px; text-align: right; margin-right: 20px; justify-content: flex-end;">
                      <div>黑名单:</div>
                    </div>
                    <div>
                      <el-checkbox v-model="white_list">电信诈骗黑名单用户自动过滤</el-checkbox>
                    </div>
                  </div>
                </div>
                <div class="kflexc" style="margin-bottom: 20px;">
                  <div class="kflexc">
                    <div class="kflexc"
                      style="width: 120px; text-align: right; margin-right: 20px; justify-content: flex-end;">
                      <div>设置库存:</div>
                    </div>
                    <div class="kflexc">
                      <el-select v-model="form.is_stock" style="width:300px;" placeholder="请选择" @change="changekucun">
                        <el-option label="不限制" value="0"></el-option>
                        <el-option label="设置库存" value="1"></el-option>
                      </el-select>
                      <div class="kucuninp" v-if="kucuninp"><el-input v-model="form.stock" style="width:300px;"
                          placeholder="输入数量"></el-input></div>
                      <div label="库存报警:" v-if="kucuninp">
                        <el-input v-model="form.warn_stock" style="width:300px;" placeholder="输入数量"></el-input>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="kflexc" style="margin-bottom: 20px;">

                  <div class="kflexc">
                    <div class="kflexc"
                      style="width: 120px; text-align: right; margin-right: 20px; justify-content: flex-end;">
                      <div>生产备注:</div>
                    </div>
                    <div>
                      <el-input v-model="form.produce_remark" style="width:300px;" placeholder="生产备注"></el-input>
                    </div>
                  </div>

                </div>
                <div class="kflexc" style="margin-bottom: 20px;">
                  <div class="kflexc"
                    style="width: 120px; text-align: right; margin-right: 20px; justify-content: flex-end;">
                    <div>结算规则:</div>
                  </div>
                  <div>
                    <div class="kflexc">
                      <el-input v-model="form.commission_rule" style="width:300px;" placeholder="结算规则"></el-input>
                      <div v-if="form.commission_rule_change_at" style="color: #595959; margin-left: 10px;">已配置</div>
                      <div v-if="form.commission_rule_change_at" style="color: #409eff; margin-left: 10px;"
                        @click="jiesuanguizelog = true">修改</div>
                      <div v-if="!form.commission_rule_change_at" style="color: #409eff; margin-left: 10px;"
                        @click="jiesuanguizelog = true">定时生效</div>
                    </div>
                  </div>
                </div>
                <el-dialog title="结算规则定时生效" :visible.sync="jiesuanguizelog" width="480px" :close-on-click-modal="false"
                  :close-on-press-escape="false">
                  <div>
                    <el-input v-model="form.change_commission_rule" style="width:300px;"
                      placeholder="结算规则生效内容"></el-input>
                  </div>
                  <div>
                    <el-date-picker type="datetime" v-model="form.commission_rule_change_at" size="medium"
                      value-format="yyyy-MM-dd HH:mm:ss" style="margin-bottom: 20px; width: 100%; margin-top: 20px;"
                      placeholder="结算规则生效时间"></el-date-picker>
                  </div>
                  <span slot="footer" class="dialog-footer">
                    <el-button @click="jiesuanguizeqingchu">清除设置</el-button>
                    <el-button type="primary" @click="jiesuanguizelog = false">确 定</el-button>
                  </span>
                </el-dialog>
                <div class="kflexc" style="margin-bottom: 20px;">
                  <div class="kflexc">
                    <div class="kflexc"
                      style="width: 120px; text-align: right; margin-right: 20px; justify-content: flex-end;">
                      <div>预估收益:</div>
                    </div>
                    <div>
                      <div class="kflexc">
                        <el-input v-model="form.expect_income" style="width: 480px !important;"
                          placeholder="预估收益"></el-input>
                        <div v-if="form.expect_income_change_at" style="color: #595959; margin-left: 10px;">已配置</div>
                        <div v-if="form.expect_income_change_at" style="color: #409eff; margin-left: 10px;"
                          @click="shouyilog = true">修改</div>
                        <div v-if="!form.expect_income_change_at" style="color: #409eff; margin-left: 10px;"
                          @click="shouyilog = true">定时生效</div>
                      </div>
                    </div>
                  </div>
                </div>
                <el-dialog title="结算规则定时生效" :visible.sync="shouyilog" width="480px" :close-on-click-modal="false"
                  :close-on-press-escape="false">
                  <div>
                    <el-input v-model="form.change_expect_income" placeholder="修改后的预估收益"></el-input>
                  </div>
                  <div>
                    <el-date-picker type="datetime" v-model="form.expect_income_change_at" size="medium"
                      value-format="yyyy-MM-dd HH:mm:ss" style="margin-bottom: 20px; width: 100%; margin-top: 20px;"
                      placeholder="预估收益定时时间"></el-date-picker>
                  </div>
                  <span slot="footer" class="dialog-footer">
                    <el-button @click="shouyiqingchu">清除设置</el-button>
                    <el-button type="primary" @click="shouyilog = false">确 定</el-button>
                  </span>
                </el-dialog>

              </div>
            </div>


            <div class="step">

              <div class="tilte kflexbc" style="width: 100%;">关联号池设置</div>
              <div class="con" style="padding: 60px; font-size: 14px; color: #666;">
                <div class="kflex" style="margin-bottom: 20px;">

                  <div class="kflexc"
                    style="width: 120px; text-align: right; margin-right: 20px; justify-content: flex-end;">
                    <div>关联号库:</div>
                  </div>
                  <div>
                    <div class="kflexc" style="margin-bottom: 20px;">
                      <el-radio v-model="pool" label="1">关联号库（提供选号）</el-radio>
                      <el-select v-model="form.pool_id" placeholder="请选择号库:">
                        <el-option v-for="item in poollist" :key="item.id" :label="item.name"
                          :value="item.id"></el-option>
                      </el-select>
                      <div style="margin-left: 30px; margin-right: 20px;">开放范围:</div>
                      <el-select v-model="form.pool_use_rang" placeholder="请选择:">
                        <el-option label="仅自己销售可用" :value="1"></el-option>
                        <el-option label="所有分销商可用" :value="2"></el-option>
                      </el-select>
                    </div>
                    <div class="kflexc" style="margin-bottom: 20px;"><el-radio v-model="pool"
                        label="2">无（不提供选号）</el-radio></div>

                  </div>

                </div>
                <!-- <div class="kflex" style="margin-bottom: 20px;">
                  <div class="kflex">
                    <div class="kflex"
                      style="width: 120px; text-align: right; margin-right: 20px; justify-content: flex-end;">
                      <div>电商平台号池关联:</div>
                    </div>
                    <div>
                      <div class="kflexbc">
                        <div style="margin-bottom: 20px;">
                          <div style="" v-for="item in form.ds_pool" :key="index">号池ID:{{item.up_pool_id}} <span
                              style="color: rgb(0, 74, 255); margin-left: 20px;"
                              @click="shanchutianmao(index)">删除</span></div>
                          <div style=""><el-button type="primary" plain @click="tianjiahaoku()">+添加天猫平台号池</el-button>
                          </div>
                        </div>
                        <div style="color: #409EFF; font-size: 14px; cursor: pointer;" @click="xiazaix()">下载使用文档</div>
                      </div>
                      <div style="font-size: 12px; color: rgb(120, 125, 133);">
                        关联后天猫号池可以从该产品的接口号池或关联号池中取号，优先走关联号库，如果您的分销商也需要天猫选号，您可以把他的号池关联至此处。</div>
                    </div>
                  </div>
                </div> -->
              </div>

            </div>


            <div class="step" style="text-align: center;" v-if="$route.query.id"><el-button type="danger"
                @click="productsave()">确认修改</el-button></div>
            <div class="step" style="text-align: center;" v-if="!$route.query.id && !$route.query.allshow"><el-button type="danger"
                @click="productsave()">发布产品</el-button></div>
            <div class="step" style="text-align: center;" v-if="!$route.query.id && $route.query.allshow"><el-button type="danger"
                @click="productsave()">下一步</el-button></div>
          </div>
        </div>
      </div>
    </div>
    <el-dialog title="关键词设置" :visible.sync="keylog" width="700px;">
      <div
        style="background: rgb(217, 230, 244); color: rgb(57, 57, 57); padding: 10px 20px; border-radius: 2px; margin:0 0 20px;">
        检测机制：您输入的关键词会与用户的收货地址进行匹配，用户的收货地址中包含该关键词则视为敏感地区不发货，
        匹配中的订单会在生产发货——订单审核——敏感地区中等待人工审核，如果您觉得无需人工审核可以在人工审核页面设置。
      </div>
      <div class="kflex">
        <upload-excel-component @on-selected-file="exportData" round plain buttonName="导入"
          class="nobtn"></upload-excel-component>
        <el-button type="text" style="margin-right: 20px;" @click="xiazai">下载模板</el-button>
        <el-button type="primary" style="margin-right: 20px;" round plain @click="xiazai2">导出当前不发货区域</el-button>
        <el-button type="primary" round plain @click="qingchu">清空所有不发货区域</el-button>
      </div>

      <div>
        <div
          style="display: flex; background: #E5E5E5; color: #707070; text-align: center; line-height: 45px; margin-top: 20px;">
          <div style="flex: 1;">敏感地区关键词</div>
          <div style="flex: 1;">关键词对应的原敏感地区
            <el-tooltip class="item" effect="light" :tabindex="20000" content="原敏感地区是运营商给的不发货地区，会用于人工再次判断是否敏感"
              placement="top">
              <i class="el-icon-question" style="color: #409EFF; font-size: 18px;"></i>
            </el-tooltip>
          </div>

        </div>
        <div class="keylist" style="max-height: 350px; overflow: auto;">
          <div style="display: flex; border: 1px #EAEAEA solid;" v-for="(item,i) in keyv" :key="i">

            <div style="flex: 1; display: flex; padding:10px;">
              <el-input v-model="item.key2" style=" margin-right: 10px;" placeholder="请输入内容"></el-input>
              <el-input v-model="item.key3" placeholder="请输入内容"></el-input>

            </div>
            <div style="flex: 1; padding:10px; display: flex;">
              <el-input v-model="item.key1" placeholder="请输入内容"></el-input>

              <i class="el-icon-delete" @click="keydel(i)"
                style=" margin-left: 5px; padding-top: 8px; cursor: pointer;"></i>
            </div>
          </div>
        </div>
        <div style="display: flex; justify-content: center; margin-top: 20px;">
          <el-button type="primary" @click="addkey">新增关键词</el-button>
        </div>

      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="keylog = false">取 消</el-button>
        <el-button type="primary" @click="keygo">确 定</el-button>
      </span>
    </el-dialog>


    <el-dialog title="自定义产品类型" :visible.sync="taglog" width="400px">
      <div class="protag">
        <el-tag :key="item.id" v-for="item in typelist" :disable-transitions="false"
          @close="handleClose(item.name)">{{item.name}}</el-tag>
        <el-input class="input-new-tag" v-if="inputVisible" v-model="inputValue" ref="saveTagInput" size="small"
          @keyup.enter.native="handleInputConfirm" @blur="handleInputConfirm">
        </el-input>
        <el-button v-else class="button-new-tag" size="small" @click="showInput">输入自定义名称</el-button>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
      </span>
    </el-dialog>
    <!-- <foot></foot> -->
    <el-dialog class="t_idcardshow" title="设置不发货前4位身份证号" :visible.sync="isidcardshow" width="1000px">
      <div style="margin-top: 17px;font-size: 13px;background-color: #D9E6F4;padding: 15px 25px;margin-bottom: 20px;">
        系统会根据身份证号前4位进行对比，对比成功则直接开卡失败，失败原因：风控身份证号前四位
      </div>
      <div style="display: flex;">
        <upload-excel-component @on-selected-file="exportDataID" buttonName="导入证件号" class="nobtn">
        </upload-excel-component>
        <el-button type="text" style="margin-bottom: 20px;margin-left: 20px;" plain @click="xiazai3">下载模板
        </el-button>
      </div>
      <el-table :data="tags" border style="width: 100%">
        <el-table-column align="center" label="不发货的身份证号前4位" prop="name">
        </el-table-column>

        <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <el-button size="mini" type="danger" @click="tagClose(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- <div>
				<el-tag
					style="margin-right: 10px;
					margin-bottom: 10px;"
					v-for="tag in tags"
					:key="tag.name"
					size="small"
					closable
					@close="tagClose(tag)"
					type="">
					{{tag.name}}
				</el-tag>
			</div> -->
      <div style="margin-bottom:17px;font-size: 16px;margin-top: 40px;">
        <el-button @click="showaddinput=true" type="primary" plain><i class="el-icon-plus"></i>增加号码</el-button>
      </div>
      <div v-if="showaddinput">
        <el-input v-model="addtaginput" size="small" type="number" style="width: 150px;" placeholder="请输入号码"></el-input>
        <el-button type="primary" size="small" @click="addtag" plain>增加</el-button>
      </div>

      <div style="text-align: center;">
        <el-button type="danger" round @click="sureaddtag">确定</el-button>
        <el-button type="info" round @click="isidcardshow=false">取消</el-button>
      </div>
    </el-dialog>

    <el-dialog title="对接电商号库" :visible.sync="tianmaolog" width="400px">
      <div class="protag">
        <el-input class="input-new-tag" v-model="tianmaoall.up_pool_id" placeholder="请输入天猫号库ID"></el-input>
      </div>
      <div class="kflexc" style="color: #409EFF;  margin-top: 10px;  cursor: pointer;" @click="tianmaolog2 = true">
        查看获取方式
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="tianmaolog = false">取 消</el-button>
        <el-button type="primary" @click="tianmaogo">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog title="获取方式" :visible.sync="tianmaolog2" width="600px">
      <img src="https://file.storep.91haoka.cn/gantanhao/tianmaohaoku3.png" style="max-width: 100%;">
      <img src="https://file.storep.91haoka.cn/gantanhao/tianmaohaoku.png" style="max-width: 100%;">
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="tianmaolog2 = false">确 定</el-button>
      </span>
    </el-dialog>

  </div>
</template>

<script>
  import {
    provinceAndCityData,
    CodeToText,
    TextToCode
  } from 'element-china-area-data'
  import UploadExcelComponent from "@/components/UploadExcel/index.vue";
  import E from 'wangeditor'
  import axios from 'axios'
  import {
    bufahuodiqu
  } from '../../assets/bufahuodiqu.js'
  import top from '@/components/top.vue'
  import left from '@/components/left.vue'
  import foot from '@/components/foot.vue'

  import {
    getsuoshuqudao
  } from '../../assets/api.js'

  export default {
    components: {
      "left": left,
      "top": top,
      "foot": foot,
      UploadExcelComponent
    },
    name: 'myDistributor',
    data() {
      return {
        options: bufahuodiqu,
        props: {
          multiple: true,
          value: 'label'
        },
        xuanzhongde: 1,
        product_services: [],
        shoufei1: false,
        shoufei2: false,
        shoufei3: false,
        shoufei4: false,
        taglog: false,
        taglist: ['类型1', '类型2'],
        inputVisible: false,
        inputValue: '',

        keylog: false,
        keyv: [{
          "key1": "",
          "key2": "",
          "key3": ""
        }],

        mingan: {
          city: "",
          citys: "",
          fixcitys: ""
        },
        randomnum: "",
        jingdongrandom: "",
        search: "",
        msg: "hello",
        log: false,
        loading: true,

        typelist: {},
        citylist: provinceAndCityData,

        poollist: "",
        pool: "2",

        tracklist: "",
        form: {
          product_source: "",
          warn_area_type: "1",
          deliver_province: [],
          tracking_company_id: "",
          pool_id: "",
          pool_use_rang: 1,
          produce_address: "",
          operator: "",
          name: "",
          sku: "",
          plan_type_id: "",
          province: "",
          city: [],
          citys: [],
          real_name_type: '0',
          produce_remark: "",
          status: "",
          comname: "",
          min_age: "",
          max_age: "",
          max_purchase: "-1",
          need_num: "0",

          haochinum: 1,
          haochival: 1,

          address_province: "",
          address_city: "",
          address_district: "",
          commission_rule: "",


          commission_rule_change_at: "", //结算规则 修改时间   例 2024-06-28 16:46:00
          change_commission_rule: "", // 结算规则定时修改的内容 字符串
          expect_income: "", //  预估收益 小数点后两位
          expect_income_change_at: "", // 预估收益定时时间 例 2024-06-28 16:46:00
          change_expect_income: "", // 修改后的预估收益 小数点后两位

          stock: "",
          is_stock: "0",
          warn_stock: "",
          is_identify_id: 0,
          id_identify: []
        },

        abstract: "",
        moneyform: {
          order_page_id: "",
          visible: '1',
          commission: 0,
          child_shop_ids: "",
          dislist: "",
          money: "",
          list: ""
        },
        kejian: false,
        sub1: true,
        sub2: true,
        sub3: false,
        sub4: true,
        showmoney: false,
        sanlist: [
          // {
          //   name: "中国联通",
          //   id: 10010
          // },
          // {
          //   name: "中国移动",
          //   id: 10086
          // },
          // {
          //   name: "中国电信",
          //   id: 10000
          // },
          {
            name: "中国广电",
            id: 10099
          },
          // {
          //   name: "虚拟运营商",
          //   id: 11111
          // }
        ],
        randomvalue: "",
        randomone: false,
        randomlog: false,
        shop_id: "",
        statusshop: false,
        url: "",

        xiaomingtime: "",
        xiaomingying: "",
        fx: true,
        fxs: {
          id: "",
          id_card: "",
          id_card_range: "",
          address_mobile: "",
          address_mobile_range: "",
          address: "",
          address_range: "",
          type: "",
          status: "",
          sitaddress: "0",
          sitmobile: "0"
        },
        fxsid: "",
        fxsidsave: "",
        fxloading: true,

        kucuninp: false,
        white_list: true,
        isidcardshow: false,
        tags: [],
        tagssure: [],
        addtaginput: '',
        showaddinput: false,
        tianmaolog: false,
        tianmaoall: {
          source: "",
          up_pool_id: ""
        },
        tianmaolog2: false,

        shouyilog: false,
        jiesuanguizelog: false,

        qudaolists: []

      }
    },
    created() {
      //地址配置,用于下载模板
      if (window.location.href.indexOf("91haoka_platform") > -1) {
        console.log("线上项目，谨慎操作。")
        this.url = window.location.origin + "/91haoka_platform/"
      } else {
        this.url = ""
      }
      if (this.$route.query.id) {
        this.getprodetail()
      }else{
        this.getfx()
        this.loading = false
      }

      //小鸣莺家用
      var xiaomingying = JSON.parse(localStorage.getItem('USER'));
      this.xiaomingying = xiaomingying.id
      //获取56
      this.gettracklist()
      this.getlists()

      //获取类型
      this.getproductstype();
      //随机生成10位数
      axios.get('/api/gth/user/shop')
        .then(response => {
          if (response.data.msg.code == 0) {
            this.shop_id = response.data.data.shop_id
          } else {
            if (response.data.msg.code == 50401) {
              that.$router.push({
                path: "/login"
              });
              return false
            }
            that.$message.error(response.data.msg.info);
          }
        })

      //获取运营商渠道
      axios.get('/api/plan-market/product/sources?page_size=2000')
        .then(response => {
          if (response.data.msg.code == 0) {
            this.qudaolists = response.data.data
          } else {
            this.$message.error(response.data.msg.info);
          }
        })



    },

    methods: {

      jiesuanguizeqingchu: function() {
        this.form.change_commission_rule = ""
        this.form.commission_rule_change_at = ""
        this.jiesuanguizelog = false
      },
      shouyiqingchu: function() {
        this.form.change_expect_income = ""
        this.form.expect_income_change_at = ""
        this.shouyilog = false
      },


      shanchutianmao: function(index) {

        this.form.ds_pool.splice(index, 1)
      },
      tianmaogo: function() {
        console.log(1)
        this.form.ds_pool.push(this.tianmaoall)
        this.tianmaolog = false
      },
      //打开添加天猫号库
      tianjiahaoku: function() {
        this.tianmaoall = {
          'source': 'tmall',
          'up_pool_id': ''
        }
        this.tianmaolog = true
      },

      qingchu: function() {
        this.mingan.fixcitys = []
        this.keyv = [{
          "key1": "",
          "key2": "",
          "key3": ""
        }]
      },
      //收费项目选择
      shoufeichange: function() {
        if (this.shoufei1 == true) {
          if (this.form.product_services.indexOf(1) == -1) {
            this.form.product_services.push(1)
          }
        } else {
          if (this.form.product_services.indexOf(1) > -1) {
            this.form.product_services.splice(this.form.product_services.findIndex(item => item.id === 1), 1)
          }

        }
        if (this.shoufei2 == true) {
          if (this.form.product_services.indexOf(2) == -1) {
            this.form.product_services.push(2)
          }
        } else {
          if (this.form.product_services.indexOf(2) > -1) {
            this.form.product_services.splice(this.form.product_services.findIndex(item => item.id === 2), 1)
          }
        }
        if (this.shoufei3 == true) {
          if (this.form.product_services.indexOf(3) == -1) {
            this.form.product_services.push(3)
          }
        } else {
          if (this.form.product_services.indexOf(3) > -1) {
            this.form.product_services.splice(this.form.product_services.findIndex(item => item.id === 3), 1)
          }
        }
        console.log(this.form.product_services)
      },
      //库存选择与显示
      changekucun: function() {
        if (this.form.is_stock == 1) {
          this.kucuninp = true
        } else {
          this.kucuninp = false
          this.form.stock = ""
          this.form.warn_stock = ""
        }
      },
      //更换默认和自定义
      changetype: function(type) {
        this.fxs.type = type
        this.fxloading = true
        this.getfx()
      },
      //更新风险全局方案
      fixfx: function() {
        var that = this;
        if (this.fxs.type == 0) {
          var sj = {
            id_card: this.fxs.id_card,
            id_card_range: this.fxs.id_card_range,
            address_mobile: this.fxs.address_mobile,
            address_mobile_range: this.fxs.address_mobile_range,
            address: this.fxs.address,
            address_range: this.fxs.address_range,
            type: this.fxs.type,
            status: this.fxs.status,
            service_id: this.fxsidsave,
            sitaddress: this.fxs.sitaddress,
            sitmobile: this.fxs.sitmobile
          }
        } else {
          var sj = {
            id_card: this.fxs.id_card,
            id_card_range: this.fxs.id_card_range,
            address_mobile: this.fxs.address_mobile,
            address_mobile_range: this.fxs.address_mobile_range,
            address: this.fxs.address,
            address_range: this.fxs.address_range,
            type: this.fxs.type,
            status: this.fxs.status,
            service_id: this.fxsid,
            sitaddress: this.fxs.sitaddress,
            sitmobile: this.fxs.sitmobile
          }
        }
        axios.post('/api/plan-market/service/update', sj)
          .then(response => {
            if (response.data.msg.code == 0) {
              that.$message({
                message: '保存成功',
                type: 'success'
              });

            } else {
              that.$message.error(response.data.msg.info);
            }
          })
      },
      //保存风险全局方案
      savefx: function() {

        var that = this;
        var sj = {
          id_card: this.fxs.id_card,
          id_card_range: this.fxs.id_card_range,
          address_mobile: this.fxs.address_mobile,
          address_mobile_range: this.fxs.address_mobile_range,
          address: this.fxs.address,
          address_range: this.fxs.address_range,
          type: this.fxs.type,
          status: this.fxs.status,
          sitaddress: this.fxs.sitaddress,
          sitmobile: this.fxs.sitmobile
        }
        axios.post('/api/plan-market/service/create', sj)
          .then(response => {
            if (response.data.msg.code == 0) {
              that.$message({
                message: '保存成功',
                type: 'success'
              });
              if (that.fxs.type == 1) {
                that.fxsid = response.data.data.id
              }
            } else {
              that.$message.error(response.data.msg.info);
            }
          })
      },
      //获取风险全局方案
      getfx: function() {

        var that = this;
        if (this.fxs.type == 0) {
          that.fx = true
          axios.get('/api/plan-market/service/index?type=0&service_id=' + this.fxsidsave)
            .then(response => {
              if (response.data.msg.code == 0) {
                if (response.data.data == null) {
                  this.fxs = {
                    id: "",
                    id_card: "",
                    id_card_range: '9999',
                    address_mobile: "",
                    address_mobile_range: '9999',
                    address: "",
                    address_range: '9999',
                    type: 0,
                    status: "",
                    sitaddress: '0',
                    sitmobile: '0'
                  }
                } else {
                  that.fxs = response.data.data
                  that.fxsidsave = response.data.data.id
                }
              } else {
                that.$message.error(response.data.msg.info);
              }
              this.fxloading = false
            })
        } else {
          this.fx = false
          axios.get('/api/plan-market/service/index?type=1&service_id=' + this.fxsid)
            .then(response => {
              if (response.data.msg.code == 0) {
                if (response.data.data == null) {
                  this.fxs = {
                    id: "",
                    id_card: "",
                    id_card_range: '9999',
                    address_mobile: "",
                    address_mobile_range: '9999',
                    address: "",
                    address_range: '9999',
                    type: 1,
                    status: "",
                    sitaddress: '0',
                    sitmobile: '0'
                  }
                } else {
                  that.fxs = response.data.data
                }
              } else {
                that.$message.error(response.data.msg.info);
              }
              this.fxloading = false
            })
        }

      },
      //手动添加关键词
      keygo: function() {
        this.mingan.citys = []
        this.mingan.fixcitys = []
        for (var i in this.keyv) {
          if (this.keyv[i].key1 != "" && this.keyv[i].key2 != "" && this.keyv[i].key3 != "") {
            this.mingan.citys.push(this.keyv[i].key1)
            var k2 = this.keyv[i].key2
            var k3 = this.keyv[i].key3
            var obj = {}
            obj[k2] = k3
            this.mingan.fixcitys.push(obj)
          }
        }
        this.keylog = false
      },
      //删除关键词
      keydel: function(i) {
        this.keyv.splice(i, 1);
      },
      //增加关键词
      addkey: function() {
        this.keyv.push({
          "key1": "",
          "key2": "",
          "key3": ""
        })
      },
      //导出已填入的敏感地区
      xiazai2: function() {
        window.location.href = '/api/plan-market/warn/area/export?id=' + this.$route.query.id
      },
      //下载
      xiazai: function() {
        const a = document.createElement('a');
        a.setAttribute('download', '敏感地区模板.xlsx');
        a.setAttribute('href', this.url + 'static/mingandiqu.xlsx');
        a.click();

      },
      //下载
      xiazai3: function() {
        const a = document.createElement('a');
        a.setAttribute('download', '导入证件号.xlsx');
        a.setAttribute('href', this.url + 'static/daoruzjh.xlsx');
        a.click();
      },

      xiazaix: function() {
        location.href = 'https://file.storep.91haoka.cn/gantanhao/tianmaoxuanhao.pdf?attname='
      },

      //获取快递公司
      gettracklist: function() {
        var that = this
        axios.get('/api/plan-market/logistics-companies')
          .then(response => {
            that.tracklist = response.data.data
          })
      },
      //获取号池
      getlists: function() {
        var that = this
        axios.get('/api/plan-market/pool/list?page=1&page_size=1000&status=1')
          .then(response => {
            that.poollist = response.data.data.data
          })
      },

      //获取产品详情
      getprodetail: function() {
        var that = this;
        axios.get('/api/plan-market/product?product_id=' + this.$route.query.id)
          .then(response => {
            if (response.data.msg.code == 0) {
              that.loading = false

              that.form = response.data.data
              //输入的4位身份证号
              if (that.form.id_identify.length != 0) {
                for (var x = 0; x < that.form.id_identify.length; x++) {
                  this.tagssure.push({
                    'name': that.form.id_identify[x]
                  })
                }
              }
              that.form.warn_area_type = that.form.warn_area_type.toString()
              if (that.form.white_list == 0) {
                that.white_list = true
              } else {
                that.white_list = false
              }

              if (that.form.product_services.indexOf(1) != -1) {
                that.shoufei1 = true
              }
              if (that.form.product_services.indexOf(2) != -1) {
                that.shoufei2 = true
              }
              if (that.form.product_services.indexOf(3) != -1) {
                that.shoufei3 = true
              }
              //查看有没有号池的id  没有就是没关联
              if (that.form.pool_id != 0) {
                that.pool = "1"
              } else {
                that.pool = "2"
                that.form.pool_id = ""
              }
              //敏感地区
              that.mingan.citys = that.form.warn_province
              that.mingan.fixcitys = that.form.warn_city

              for (var i in that.mingan.citys) {
                that.keyv.push({
                  "key1": "",
                  "key2": "",
                  "key3": ""
                })

              }

              for (var m in that.keyv) {
                that.keyv[m].key1 = that.mingan.citys[m]

                for (var n in that.mingan.fixcitys[m]) {
                  that.keyv[m].key2 = n
                  that.keyv[m].key3 = that.mingan.fixcitys[m][n]
                }
              }

              var city = []
              if (that.form.province != "") {
                try {
                  city.push(TextToCode[that.form.province].code)
                } catch (err) {
                  console.log('没有这个地址对应的号码')
                }

              }
              if (that.form.city != "") {
                try {
                  city.push(TextToCode[that.form.province][that.form.city].code)
                } catch (err) {
                  console.log('没有这个地址对应的号码')
                }

              }
              that.form.citys = city

              that.changekucun()

              that.xiaomingtime = response.data.data.max_purchase_time

              //获取到service_id后在获取方式
              axios.get('/api/plan-market/service/index?service_id=' + response.data.data.service_id)
                .then(response => {
                  if (response.data.msg.code == 0) {
                    if (response.data.data == null) {
                      //获取默认方案
                      axios.get('/api/plan-market/service/index?type=0')
                        .then(response => {
                          if (response.data.msg.code == 0) {
                            if (response.data.data == null) {
                              this.fxs = {
                                id: "",
                                id_card: "",
                                id_card_range: '9999',
                                address_mobile: "",
                                address_mobile_range: '9999',
                                address: "",
                                address_range: '9999',
                                type: 0,
                                status: "",
                                sitaddress: "0",
                                sitmobile: "0"
                              }
                            } else {
                              that.fxs = response.data.data
                              that.fxsidsave = response.data.data.id
                            }
                          } else {
                            that.$message.error(response.data.msg.info);
                          }

                          this.fxloading = false
                        })

                    } else {
                      //如果是自定义就获取一下全局的方式
                      if (response.data.data.type == 1) {
                        that.fx = false
                        that.fxsid = response.data.data.id
                        //获取到service_id后在获取全局方式
                        axios.get('/api/plan-market/service/index?type=0')
                          .then(response => {
                            if (response.data.msg.code == 0) {
                              if (response.data.data == null) {
                                this.fxs = {
                                  id: "",
                                  id_card: "",
                                  id_card_range: "",
                                  address_mobile: "",
                                  address_mobile_range: "",
                                  address: "",
                                  address_range: "",
                                  type: 0,
                                  status: ""
                                }
                              } else {
                                that.fxsidsave = response.data.data.id
                              }
                            } else {
                              that.$message.error(response.data.msg.info);
                            }

                            this.fxloading = false
                          })
                      } else {
                        that.fx = true
                        that.fxsidsave = response.data.data.id
                      }
                      that.fxs = response.data.data
                      that.fxloading = false
                    }

                  } else {
                    that.$message.error(response.data.msg.info);
                  }
                  console.log(that.fxsidsave)
                })
            } else {
              that.$message.error(response.data.msg.info);
            }
          })
      },

      //产品名验证唯一性
      nijiushiwodeweiyi1: function() {
        var that = this;
        axios.get('/api/plan-market/product/name/isexist?name=' + that.form.name)
          .then(response => {
            if (response.data.msg.code == 0) {
              this.sub1 = true
            } else {
              this.sub1 = false
              that.$message.error(response.data.msg.info);
            }
          })
      },
      //产品编号验证唯一性
      nijiushiwodeweiyi2: function() {
        var that = this;
        axios.get('/api/plan-market/product/sku/isexist?sku=' + this.form.sku)
          .then(response => {
            if (response.data.msg.code == 0) {
              this.sub2 = true
            } else {
              this.sub2 = false
              that.$message.error(response.data.msg.info);
            }
          })
      },
      //商品名验证唯一性
      nijiushiwodeweiyi3: function() {
        var that = this;
        axios.get('/api/plan-market/order-page/name/isexist?title=' + this.shopform.title)
          .then(response => {
            if (response.data.msg.code == 0) {
              this.sub3 = true
            } else {
              this.sub3 = false
              that.$message.error(response.data.msg.info);
            }
          })
      },

      //身份证审核
      cardid: function() {
        this.moneyform.child_shop_ids = "";
        if (this.moneyform.visible == 3 || this.moneyform.visible == 4) {
          this.kejian = true
        }
        if (this.moneyform.visible == 1 || this.moneyform.visible == 2) {
          this.kejian = false
        }
      },

      //保存产品
      productsave: function() {
        // if(this.fxsidsave == ''){
        //   this.$message.error('请选择或者填写风控选项');
        //   return false
        // }
        if (JSON.parse(localStorage.getItem('SHOP')).shop_id == 50481 || JSON.parse(localStorage.getItem('SHOP'))
          .shop_id == 304676) {
          if (this.form.product_source == '') {
            this.$message.error('请填写所属渠道');
            return false
          }
        }
        if (this.sub1 == false || this.sub2 == false || this.sub4 == false || this.form.name == "" || this.form.sku ==
          "") {
          return false
        }
        //发布还是仅保存


        if (this.form.address_province == undefined) {
          this.form.address_province = this.form.province
          this.form.address_city = this.form.city
        }
        let white_list
        if (this.white_list == true) {
          white_list = 0
        } else {
          white_list = 1
        }
        //身份证号码数组
        var id_identify = []
        for (var x = 0; x < this.tagssure.length; x++) {
          id_identify.push(this.tagssure[x].name)
        }
        var that = this;
        if (this.fxs.type == 0) {
          var formData = {
            product_source: this.form.product_source,
            warn_area_type: this.form.warn_area_type,
            deliver_province: this.form.deliver_province,
            white_list: white_list,
            product_id: this.$route.query.id,
            name: this.form.name,
            sku: this.form.sku,
            operator: this.form.operator,
            plan_type_id: this.form.plan_type_id,
            province: this.form.address_province,
            city: this.form.address_city,
            real_name_type: this.form.real_name_type,
            produce_remark: this.form.produce_remark,
            max_purchase: this.form.max_purchase,
            min_age: this.form.min_age,
            max_age: this.form.max_age,
            // status:this.form.status,
            produce_address: this.form.produce_address,
            commission_rule: this.form.commission_rule,

            commission_rule_change_at: this.form.commission_rule_change_at, //结算规则 修改时间   例 2024-06-28 16:46:00
            change_commission_rule: this.form.change_commission_rule, // 结算规则定时修改的内容 字符串
            expect_income: this.form.expect_income, //  预估收益 小数点后两位
            expect_income_change_at: this.form.expect_income_change_at, // 预估收益定时时间 例 2024-06-28 16:46:00
            change_expect_income: this.form.change_expect_income, // 修改后的预估收益 小数点后两位


            pool_use_rang: this.form.pool_use_rang,
            warn_province: this.mingan.citys,
            warn_city: this.mingan.fixcitys,
            // tracking_company_id:this.form.tracking_company_id,
            abstract: this.abstract,
            need_num: this.form.need_num,
            max_purchase_time: this.xiaomingtime,
            service_id: this.fxsidsave,
            is_stock: this.form.is_stock,
            stock: this.form.stock,
            warn_stock: this.form.warn_stock,
            product_services: this.form.product_services,
            is_identify_id: this.form.is_identify_id,
            id_identify: id_identify,
            is_force_recharge: this.form.is_force_recharge,
            ds_pool: this.form.ds_pool
          }
        } else {
          var formData = {
            product_source: this.form.product_source,
            warn_area_type: this.form.warn_area_type,
            deliver_province: this.form.deliver_province,
            white_list: white_list,
            product_id: this.$route.query.id,
            name: this.form.name,
            sku: this.form.sku,
            operator: this.form.operator,
            plan_type_id: this.form.plan_type_id,
            province: this.form.address_province,
            city: this.form.address_city,
            real_name_type: this.form.real_name_type,
            produce_remark: this.form.produce_remark,
            max_purchase: this.form.max_purchase,
            min_age: this.form.min_age,
            max_age: this.form.max_age,
            // status:this.form.status,
            produce_address: this.form.produce_address,
            commission_rule: this.form.commission_rule,

            commission_rule_change_at: this.form.commission_rule_change_at, //结算规则 修改时间   例 2024-06-28 16:46:00
            change_commission_rule: this.form.change_commission_rule, // 结算规则定时修改的内容 字符串
            expect_income: this.form.expect_income, //  预估收益 小数点后两位
            expect_income_change_at: this.form.expect_income_change_at, // 预估收益定时时间 例 2024-06-28 16:46:00
            change_expect_income: this.form.change_expect_income, // 修改后的预估收益 小数点后两位

            pool_use_rang: this.form.pool_use_rang,
            warn_province: this.mingan.citys,
            warn_city: this.mingan.fixcitys,
            // tracking_company_id:this.form.tracking_company_id,
            abstract: this.abstract,
            need_num: this.form.need_num,
            max_purchase_time: this.xiaomingtime,
            service_id: this.fxsid,
            is_stock: this.form.is_stock,
            stock: this.form.stock,
            warn_stock: this.form.warn_stock,
            product_services: this.form.product_services,
            is_identify_id: this.form.is_identify_id,
            id_identify: id_identify,
            is_force_recharge: this.form.is_force_recharge,
            ds_pool: this.form.ds_pool
          }
        }

        if (this.pool == 1) {
          formData.pool_id = this.form.pool_id
        }

        if(this.$route.query.id){
          axios.post('/api/plan-market/product', formData)
            .then(response => {
              if (response.data.msg.code == 0) {
                that.$message.success("修改成功");
                that.$router.push({
                  path: '/productionBasismanag'
                })
              } else {
                that.$message.error(response.data.msg.info);
              }
            })
        }else{
          axios.post('/api/gth/products/release', formData)
          	.then(response => {
          		if (response.data.msg.code == 0) {
          			if (that.allshow == true) {
          				that.$router.push({
          					path: '/productionDelivery/addShop?allshow=allshow&id=' + response.data.data.id
          				})
          			} else {
          				that.$message({
          					message: '发布成功！',
          					type: 'success'
          				});
          				that.$router.push({
          					path: '/productionBasismanag'
          				})
          			}
          		} else {
          			that.$message.error(response.data.msg.info);
          		}
          	})
        }
      },


      //单个图片上传
      uploadok: function(file) {
        var that = this;
        var formData = new FormData();
        formData.append("pic", file.raw);
        axios.post('/api/plan-market/order-page/upload-pic', formData)
          .then(response => {
            if (response.data.msg.code == 0) {
              that.shopform.image1 = response.data.data
            } else {
              that.$message.error(response.data.msg.info);
            }
          })
      },
      //选择省市区
      changeaddress: function(v) {
        this.form.address_province = CodeToText[v[0]],
          this.form.address_city = CodeToText[v[1]]
      },
      //导入敏感地区
      exportData: function(data) {

        this.mingan.citys = []
        this.mingan.fixcitys = []
        for (var i = 0; i < data.results.length; i++) {
          this.mingan.citys.push(data.results[i]['敏感地区'])

          if (data.results[i]['修改敏感地区'].indexOf(",") > -1) {
            var arr = data.results[i]['修改敏感地区'].split(',')
          } else if (data.results[i]['修改敏感地区'].indexOf("，") > -1) {
            var arr = data.results[i]['修改敏感地区'].split('，')
          } else {
            return false
            that.$message.error("数据出错了，请检查格式");
          }
          var obj = {}
          obj[arr[0]] = arr[1]
          this.mingan.fixcitys.push(obj)

          var obj2 = {}
          obj2['key1'] = data.results[i]['敏感地区']
          obj2['key2'] = arr[0]
          obj2['key3'] = arr[1]

          this.keyv.push(obj2)
        }
        console.log(this.mingan.citys)
        console.log(this.mingan.fixcitys)
        this.$message({
          message: '导入成功，共计' + this.mingan.citys.length + '条',
          type: 'success'
        });
      },
      //获取产品类型
      getproductstype: function() {
        var that = this
        axios.get("/api/gth/plan-type")
          .then(function(response) {
            if (response.data.msg.code == 0) {
              that.typelist = response.data.data
            } else {
              that.$message.error(response.data.msg.info);
            }

          })
      },

      //自定义产品类型
      handleClose(tag) {
        this.taglist.splice(this.taglist.indexOf(tag), 1);
      },

      showInput() {
        this.inputVisible = true;
        this.$nextTick(_ => {
          this.$refs.saveTagInput.$refs.input.focus();
        });
      },

      handleInputConfirm() {
        var that = this;
        var formData = new FormData();
        formData.append("name", this.inputValue);
        axios.post('/api/gth/plan-type/release', formData)
          .then(response => {
            if (response.data.msg.code == 0) {
              that.getproductstype();
              that.$message({
                message: '添加成功',
                type: 'success'
              });
            } else {
              that.$message.error(response.data.msg.info);
            }
          })
        let inputValue = this.inputValue;
        if (inputValue) {
          this.taglist.push(inputValue);
        }
        this.inputVisible = false;
        this.inputValue = '';
      },
      idcardshow() {
        this.tags = JSON.parse(JSON.stringify(this.tagssure))
        this.isidcardshow = true
      },
      tagClose(tag) {
        this.tags.splice(this.tags.indexOf(tag), 1);
      },
      addtag() {
        if (this.addtaginput != '' && this.addtaginput.length == 4) {
          this.tags.push({
            'name': this.addtaginput
          })
          this.addtaginput = ''
        } else {
          this.$message.error('请输入身份证号前4位');
        }
      },
      sureaddtag() {
        this.tagssure = JSON.parse(JSON.stringify(this.tags))
        this.isidcardshow = false
      },
      //导入身份证号
      exportDataID: function(data) {
        console.log(data.results)
        for (var i = 0; i < data.results.length; i++) {
          this.tags.push({
            'name': data.results[i]['不发货的身份证号前4位']
          })
        }
      },
    }

  }
</script>

<style lang="scss" scoped>
  /deep/ .el-input__inner {
    background: #F3F5F8 !important;
    border: 1px #F3F5F8 solid;
  }

  .bai {
    /deep/ .el-input__inner {
      background: #fff !important;
      border: 1px #fff solid !important;
    }
  }

  /deep/ .el-icon-question {
    font-size: 18px !important;
    color: #0C83FF !important;
  }

  .fxli {
    text-align: center;
    margin-right: 20px;
    width: 150px;
    line-height: 40px;
    cursor: pointer;
  }

  .fxact {
    position: relative;
    color: #2974FF !important;

    &::after {
      content: '';
      position: absolute;
      height: 3px;
      border-radius: 2px;
      background: #2974FF;
      width: 20px;
      left: 50%;
      margin-left: -10px;
      bottom: 0;
    }
  }

  .index {
    .nobtn /deep/ .el-button--primary {
      margin-right: 20px;
      border-radius: 20px;
      color: #409EFF;
      background: #ecf5ff;
      border-color: #b3d8ff;
    }

    /deep/ .el-message-box__wrapper {
      z-index: 20000 !important;
    }

    .zengzhi {
      color: #FF3B3B;
      margin-left: 10px;

      /deep/ .el-checkbox {
        margin-right: 0;
      }

      i {
        font-size: 20px;
        margin-left: 0px !important;
        margin-right: 10px;
      }

      a {
        color: #1989FA;
      }
    }

    .xiaoming {
      display: flex;

      /deep/ .el-form-item {
        flex: 1;
      }
    }

    .san {
      /deep/ .el-input {
        width: 150px !important;
      }
    }

    // #editor{
    //     .w-e-text-container{ z-index: 1999 !important;}
    //     .w-e-menu{ z-index: 1999 !important;}
    // }

    .loglist {
      display: flex;
      justify-content: space-between;
      margin-bottom: 30px;

      .log_title {
        padding: 7px 10px;
      }
    }

    .listl {
      height: 350px;
      overflow: auto;

      /deep/ .el-input__inner {
        border: none;
        text-align: center
      }
    }

    .list {

      display: flex;
      text-align: center;
      color: #727272;
      line-height: 45px;
      border: 1px #EAEAEA solid;
      margin-top: -1px;

      .th {
        flex: 1;
        background: #F9F9F9;
        font-size: 14px;
      }

      .td {
        flex: 1;
        font-size: 14px;
        border-right: 1px #EAEAEA solid;
      }
    }

    /deep/ .el-pagination {
      text-align: right;
      margin: 20px 0
    }

    // /deep/ .el-dialog__wrapper{ z-index: 19999 !important;}
    .keyd {
      display: flex;

      .is-plain {
        height: 30px;
        line-height: 30px;
        padding: 0 10px;
        margin-left: 10px;
      }

      #drop {
        .el-button--primary {
          background: #409EFF;
          border: 1px #409eff solid;
          height: 30px;
          line-height: 30px;
          padding: 0 20px;
        }
      }
    }

    .protag {
      /deep/ .el-tag {
        margin-right: 20px;
        margin-bottom: 20px;
      }
    }

    .addpro {
      overflow: hidden;

      /deep/ .el-steps {
        width: 100%;
        padding: 30px;
      }

      .kucunset {
        width: 300px;
      }

      .kucuninp {
        margin-left: 10px;
        margin-top: 2px;
      }

      .step {
        margin-bottom: 20px;
        background: #FFFFFF;

        .redbor {
          /deep/ .el-input__inner {
            border: 1px #EEF7FF solid;
          }
        }

        .tilte {
          background: #F9F9F9;
          padding-left: 30px;
          line-height: 45px;
          font-size: 14px;

          span {
            background: #B1E4FF;
            color: #FFFFFF;
            float: right;
            line-height: 15px;
            cursor: pointer;
            padding: 5px 0;
            display: block;
            width: 24px;
            text-align: center;
            margin-right: 20px;
            margin-top: 8px;
            border-radius: 14px;
          }
        }

        .w330 {
          /deep/ .el-input__inner {
            width: 330px !important;
          }
        }

        .w480 {
          /deep/ .el-input__inner {
            width: 480px !important;
          }
        }

        .con {
          background: #FFFFFF;
          padding: 35px;

          .flex {
            display: flex;
          }

          .ori3 {
            i {
              font-size: 25px;
              color: #409EFF;
              position: relative;
              top: 3px;
              margin-left: 15px;
            }
          }

          .ori {
            background: #FBFBFB;
            padding: 20px 10px;

            .fx {
              display: flex;
              position: relative;
              left: -10px;
              top: -20px;
              background: #FFFFFF;

              .fxli {
                flex-basis: 200px;
                text-align: center;
                border-top: 3px #FFFFFF solid;
                line-height: 40px;
                cursor: pointer;
              }

              .fxact {
                background: #FBFBFB;
                border-top: 3px #EEF7FF solid;
              }
            }

            .fxbtm {
              display: flex;
              padding-left: 50px;

              .red {
                margin-left: 20px;
                color: #FF3B3B;
              }
            }

            .hui {
              color: #999;
            }

            /deep/ .el-input {
              width: 300px;
            }

            /deep/ .el-form-item {
              margin-bottom: 20px;
            }

            /deep/ .el-form-item__label {
              width: 150px !important;
            }

            .age .el-input {
              width: 150px;
            }

            .wenhao2 {
              color: #999;
              font-size: 14px;
            }

            .no {
              display: flex;
              align-items: center;

              #drop {
                .el-button--primary {
                  background: #409EFF;
                  border: 1px #409EFF solid;
                }
              }

              .nonum {
                background: #409EFF;
                padding: 0px 10px;
                line-height: 35px;
                height: 35px;
                color: #FFFFFF;
                border-radius: 3px;
                display: block;
              }

              .el-button {}

              span {
                margin: 0 20px;
              }
            }

          }
        }

        .haochi {
          /deep/ .el-radio__label {
            line-height: 40px;
          }

          /deep/ .el-select {
            margin-left: 20px;
          }
        }

        .btm0 {
          /deep/ .el-button {
            margin-left: 20px;
          }

          /deep/ .el-form-item {
            margin-bottom: 0;
          }
        }

        .label200 .el-form-item__label {
          width: 149px !important;
        }

        .avatar-uploader .el-upload {
          border: 1px dashed #d9d9d9;
          border-radius: 6px;
          cursor: pointer;
          position: relative;
          overflow: hidden;
        }

        .avatar-uploader .el-upload:hover {
          border-color: #409EFF;
        }

        .avatar-uploader-icon {
          font-size: 28px;
          color: #8c939d;
          width: 178px;
          height: 178px;
          line-height: 178px;
          text-align: center;
        }

        .avatar {
          width: 178px;
          height: 178px;
          display: block;
        }

        .wenhao {
          background: #B1E4FF;
          color: #FFFFFF;
          line-height: 15px;
          cursor: pointer;
          padding: 5px 11px;
          margin-left: 20px;
          text-align: center;
          border-radius: 14px;
        }
      }

    }
  }
</style>
